﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;
using System.ComponentModel;

namespace Doo.Controls
{
    /// <summary>
    /// 模板，目前仅包含文本
    /// </summary>
    [DefaultProperty("Text")]
    [ParseChildren(true,"Text")]
    [ControlBuilder(typeof(TemplateControlBuilder))]
    public class Template
    {
        /// <summary>
        /// 当前模版组中的唯一ID
        /// </summary>
        public string ID { get; set; }

        /// <summary>
        /// 模板内容
        /// </summary>
        [Bindable(true)]
        [PersistenceMode(PersistenceMode.EncodedInnerDefaultProperty)]
        public string Text { get; set; }

    }

    public class TemplateControlBuilder : ControlBuilder
    {
        public override bool AllowWhitespaceLiterals()
        {
            return false;
        }

        public override Type GetChildControlType(string tagName, System.Collections.IDictionary attribs)
        {
            if (string.Compare(tagName, "template", true) == 0) return typeof(Template);

            return base.GetChildControlType(tagName, attribs);
        }
    }
}
